package com.cnjson.sensor.protocolARP.waterQualitySensorProtocol.controlEquipmentResponse;

import com.cnjson.sensor.protocolARP.waterQualitySensorProtocol.WaterQualitySensorResolveInterface;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;

@Component
public class ShutdownEquipmentResponse implements WaterQualitySensorResolveInterface {

    private static final Logger logger = LoggerFactory.getLogger(ShutdownEquipmentResponse.class);
//
//    @Autowired
//    private CtrlEquipmentService equipmentStateService ;



    @Override
    public byte[] resolve(String[]  data, SocketChannel client) {
//
        //将这些状态记录到数据库中，可以查看
//        byte[] equipmentNo = ByteUtil.getData(data, 3, 2);
//        byte[] channelNo = ByteUtil.getData(data, 7, 1);
//        byte[] state = ByteUtil.getData(data, 8, 1);
//        //更新控制设备状态日志
//        equipmentStateService.updateCtrlEquipmentState(String.valueOf(Integer.parseInt(SocketServer.byteToHexString(state), 16)), String.valueOf(Integer.parseInt(SocketServer.byteToHexString(equipmentNo), 16)), String.valueOf(Integer.parseInt(SocketServer.byteToHexString(channelNo), 16) + 1));
//        String equipment = SocketServer.hexStringToString(equipmentNo);
//        String channel = String.valueOf(Integer.parseInt(SocketServer.hexStringToString(channelNo)) + 1);
//        //控制成功，修改日志
//        equipmentStateService.updateCtrlEquipmentLog(equipment, channel, "1", "0");
//        //修改控制设备状态
//        equipmentStateService.updateCtrlEquipment(equipment + "-" + channel, "0");
        return null;
    }
}
